package com.hskn.hss.module.employeeCorrectRecord.controller;


import com.hskn.hss.core.annotation.SysLog;
import com.hskn.hss.core.enums.BusinessType;
import com.hskn.hss.entity.AjaxResult;
import com.hskn.hss.module.casesetissuesource.mapper.CasesetIssueSourceMapper;
import com.hskn.hss.module.empPlan.entity.EmpPlan;
import com.hskn.hss.module.employeeCorrectRecord.entity.EmployeeCorrectRecord;
import com.hskn.hss.module.employeeCorrectRecord.mapper.EmployeeCorrectRecordMapper;
import com.hskn.hss.module.employeeCorrectRecord.service.EmployeeCorrectRecordService;
import com.hskn.hss.module.employeeCorrectRecord.to.EmployeeCorrectRecordTo;
import com.hskn.hss.module.employeeCorrectRecord.vo.EmployeeCorrectRecordPageVo;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiResponse;
import io.swagger.annotations.ApiResponses;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;


/**
 * <p>
 * 前端控制器
 * </p>
 *
 * @author hskn
 * @since 2021-05-21
 */
@Slf4j
@RestController
@RequestMapping("/hss/employeeCorrectRecord")
public class EmployeeCorrectRecordController {

    @Autowired
    private EmployeeCorrectRecordService employeeCorrectRecordService;


    @ApiOperation(value = "考勤纠正记录接口", notes = "考勤纠正记录")
    @ApiResponses({
            @ApiResponse(code = 200, message = "ok", response = EmployeeCorrectRecordPageVo.class)
    })
    @PostMapping("attendanceCorrectRecord")
    public AjaxResult<Object> attendanceCorrectRecord(@RequestBody @Validated EmployeeCorrectRecordTo employeeCorrectRecordTo) {
        try {
            return AjaxResult.success(employeeCorrectRecordService.attendanceCorrectRecord(employeeCorrectRecordTo));
        } catch (Exception e) {

            e.printStackTrace();
            log.error("报错ERROR", e);
            return AjaxResult.fail("操作失败");
        }
    }

    @SysLog(businessType = BusinessType.INSERT, tableName = "employee_correct_record", bean = EmployeeCorrectRecord.class, beanMapper = EmployeeCorrectRecordMapper.class, names = "employeeName")
    @ApiOperation(value = "考勤纠正修改接口", notes = "考勤纠正修改")
    @ApiResponses({
            @ApiResponse(code = 200, message = "ok")
    })
    @PostMapping("insertEmployeeCorrectRecord")
    public AjaxResult<Object> insertEmployeeCorrectRecord(@RequestBody @Validated EmployeeCorrectRecordTo employeeCorrectRecordTo) {
        try {
            employeeCorrectRecordService.insertEmployeeCorrectRecord(employeeCorrectRecordTo);
            return AjaxResult.success("操作成功");
        } catch (Exception e) {

            e.printStackTrace();
            log.error("报错ERROR", e);
            return AjaxResult.fail("操作失败");
        }
    }

    @SysLog(businessType = BusinessType.UPDATE, tableName = "employee_correct_record", idKey = "casesetIssueSourceId", bean = EmployeeCorrectRecord.class, beanMapper = EmployeeCorrectRecordMapper.class, names = "employeeName")
    @ApiOperation(value = "考勤纠正恢复接口", notes = "考勤纠正恢复")
    @ApiResponses({
            @ApiResponse(code = 200, message = "ok")
    })
    @PostMapping("updateEmployeeCorrectRecord")
    public AjaxResult<Object> updateEmployeeCorrectRecord(@RequestBody @Validated EmployeeCorrectRecordTo employeeCorrectRecordTo) {
        try {
            return AjaxResult.success(employeeCorrectRecordService.updateEmployeeCorrectRecord(employeeCorrectRecordTo));
        } catch (Exception e) {

            e.printStackTrace();
            log.error("报错ERROR", e);
            return AjaxResult.fail("操作失败");
        }
    }

}

